class Student {
    String name;
    int age;
    private char sex;

    Student() {
        System.out.printf("Student init....\n");
        name = new String();
        age = 20;
        sex = 'M';
    }

    Student(String name) {
        System.out.printf("Student init name....\n");
        this.name = name;
    }

    Student(String name, int age) {
        System.out.printf("Student init name age....\n");
        this.name = name;
        this.age = age;
    }

    Student(String name, int age, char sex) {
        System.out.printf("Student init name age sex....\n");
        this.name = name;
        this.age = age;
        this.sex = sex;
    }

    Student show() {
        System.out.printf("name = %s, age = %d, sex = %c\n", name, age, sex);
        return this;
    }
}

class SmallStudent extends Student {
    String name = "王二";

    SmallStudent() {}
    SmallStudent(String name, int age, char sex) {
        super(name, age, sex);
        System.out.printf("SmallStudent init ....!\n");
    }

    SmallStudent show() {
        super.show();
        System.out.printf("SmallStudent show ....\n");
        return this;
    }

    public String toString() {
        return "我重写了ToString方法!!!!!";
    }

    void talk() {
        String name = "李四";
        System.out.printf("name = %s, parent = %s SmallStudent %s talk...!\n",
                                this.name, super.name, name);
    }

    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    public void finalize() {
        System.out.printf("销毁时自动调用的方法!\n");
    }
}

public class ExtendsTest {
    static public void main(String [] args) {
        SmallStudent a = new SmallStudent("张三", 25, 'F');
        a.age = 15;

        a.talk();
        a.show();

        // SmallStudent b = a;
        a = null;
        System.gc();
        // System.out.println(a);
    }
}
